﻿@*@model IEnumerable<Business.DbConnect.Customer>*@
@model PagedList.IPagedList<Business.DbConnect.Customer>
@{
    ViewBag.Title = "Khách";
}
<link href="@Url.Content("../../../../Content/bPopup.css")" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="@Url.Content("../../../../Scripts/jquery.bpopup-0.7.0.min.js")"></script>
<script type="text/javascript">
    function InitAll() {
        $('#btnSubmit').click(function () {
            $.ajax({
                url: '@Url.Action("Search", "Customer")',
                dataType: 'html',
                type: 'POST',
                data: { "sContent": $('#txtSearch').val() },
                success: function (data) {
                    $('#tableList').html(data);
                }
            });
        });
        $('.editLink').bind('click', function (e) {
            e.preventDefault();
            var id = $(this).attr("lId");
            $('#popup').bPopup({
                onOpen: function () {
                    $('#popup').bPopup({
                        content: 'iframe', //'iframe' or 'ajax'
                        contentContainer: '.container',
                        loadUrl: 'http://localhost:4647/Customer/Edit/' + id //Uses jQuery.load()
                    }, function () {
                        $('iframe').load(function () {
                            $('iframe').css({ 'height': '420px', 'width': '400px' });
                            $('#popup').css('min-width', '400px');
                        });
                    });
                },
                onClose: function () {
                    $('iframe').remove();
                    $.ajax({
                        url: '@Url.Action("listCustomer", "Customer")',
                        dataType: 'html',
                        type: 'post',
                        success: function (data) {
                            $('#tableList').html(data);
                        }
                    });
                }
            });
        });
        $('.createLink').bind('click', function (e) {
            e.preventDefault();
            var id = $(this).attr("lId");
            $('#popup').bPopup({
                onOpen: function () {
                    $('#popup').bPopup({
                        content: 'iframe', //'iframe' or 'ajax'
                        contentContainer: '.container',
                        loadUrl: 'http://localhost:4647/Customer/Create/'//Uses jQuery.load()
                    }, function () {
                        $('iframe').load(function () {
                            $('iframe').css({ 'height': '389px', 'width': '400px' });
                            $('#popup').css('min-width', '400px');
                        });
                    });
                },
                onClose: function () {
                    $('iframe').remove();
                    $.ajax({
                        url: '@Url.Action("listCustomer", "Customer")',
                        dataType: 'html',
                        type: 'post',
                        success: function (data) {
                            $('#tableList').html(data);
                        }
                    });
                }
            });
        });
    }
    $(function () {
        InitAll();
        $(document).ajaxSuccess(function () { InitAll(); });
    });
</script>
<div id="content">
    <h2>
        Khách</h2>
    <p>
        <a href="#" class="createLink"><span class="bt_green_lft"></span><strong>Thêm Khách</strong>
            <span class="bt_green_r"></span></a>
    </p>
    <div class="sidebar_search">
        <input type="text" id="txtSearch" name="SearchName" class="search_input" />
        <input type="image" id="btnSubmit" name="Search" value="Tìm kiếm" class="search_submit" src="@Url.Content("~/Content/in-admin-panel/images/search.png")"/>
    </div>
    <br />
    <br />
    <div id="tableList">
        @Html.Partial("listCustomer", Model)
    </div>
    <div id="popup">
        <span class="button bClose"><span>X</span> </span>
        <div class="container">
        </div>
    </div>
</div>